<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;

class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;

    public function success($data = array())
    {
        $result = array(
            'code' => 0,
            'msg' => '成功',
            'data' => $data,
        );
        return response()->json($result);
    }

    public function fail($msg = '参数缺失',$data = array())
    {
        $result = array(
            'code' => 400,
            'msg' => $msg,
            'data' => $data,
        );
        return response()->json($result);
    }

    public function shopfail($msg = '商户不存在',$data = array())
    {
        $result = array(
            'code' => 401,
            'msg' => $msg,
            'data' => $data,
        );
        return response()->json($result);
    }

    public function payfail($msg = '金额异常',$data = array())
    {
        $result = array(
            'code' => 402,
            'msg' => $msg,
            'data' => $data,
        );
        return response()->json($result);
    }

    public function freig($msg = '机器离线',$data = array())
    {
        $result = array(
            'code' => 404,
            'msg' => $msg,
            'data' => $data,
        );
        return response()->json($result);
    }

    public function expir($msg = '设备过期',$data = array())
    {
        $result = array(
            'code' => 405,
            'msg' => $msg,
            'data' => $data,
        );
        return response()->json($result);
    }

    public function expirss($msg = '退款失败',$data = array())
    {
        $result = array(
            'code' => 408,
            'msg' => $msg,
            'data' => $data,
        );
        return response()->json($result);
    }

    public function buying($msg = '有顾客在售卖中稍后重试',$data = array())
    {
        $result = array(
            'code' => 300,
            'msg' => $msg,
            'data' => $data,
        );
        return response()->json($result);
    }

    public function expirimg($msg = '广告过期',$data = array())
    {
        $result = array(
            'code' => 407,
            'msg' => $msg,
            'data' => $data,
        );
        return response()->json($result);
    }
}
